package service

import (
	"guliedu/model"
	"guliedu/repository"
	"mime/multipart"
)

type IEduVideoService interface {
	Insert(video *model.EduVideo) error
	UploadVideo(file multipart.File, fileSize int64) (string, int)
	Select(id string) (*model.EduVideo, error)
	Update(video *model.EduVideo) error
	Delete(id string) error
	SelectByChapterID(id string) ([]model.EduVideo, error)
	DeleteByCourseID(id string) error
}

func NewIEduVideoService() IEduVideoService {
	return &EduVideoService{EduVideoRepository: repository.NewIEduVideoRepository()}
}

type EduVideoService struct {
	EduVideoRepository repository.IEduVideoRepository
}

func (t *EduVideoService) Insert(video *model.EduVideo) error {
	return t.EduVideoRepository.Insert(video)
}

func (t *EduVideoService) UploadVideo(file multipart.File, fileSize int64) (string, int) {
	return t.EduVideoRepository.UploadVideo(file, fileSize)
}

func (t *EduVideoService) Select(id string) (*model.EduVideo, error) {
	return t.EduVideoRepository.Select(id)
}

func (t *EduVideoService) Update(video *model.EduVideo) error {
	return t.EduVideoRepository.Update(video)
}

func (t *EduVideoService) Delete(id string) error {
	return t.EduVideoRepository.Delete(id)
}

func (t *EduVideoService) SelectByChapterID(id string) ([]model.EduVideo, error) {
	return t.EduVideoRepository.SelectByChapterID(id)
}

func (t *EduVideoService) DeleteByCourseID(id string) error {
	return t.EduVideoRepository.DeleteByCourseID(id)
}
